﻿using INTEX.DataBase.Tools;
using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class VVKPOS
    {

        public void YGRVKP()
        {
            dwData = TBMain.NewRow();
            dwData["VKPMANDANT"] = app.Mandant;
            dwData["VKPAUFKRS"] = KRS;
            if (KRS == "")
            {
                dwData["VKPAUFKRS"] = "AA";
            }
            dwData["VKPAUFLFD"] = LFD;
            if (LFD == "000000")
            {
                dwData["VKPAUFLFD"] = "";
            }
            dwData["VKPKUNDNR"] = _KUNDNR;
            dwData["VKPKDBEZ"] = _YARNTYP;
            dwData["VKPAENDST"] = _YNE;
            dwData["VKPART"] = _SPINLOT;
            dwData["VKPSACHBE"] = _SACHBE;
            dwData["VKPFILLER2"] = _BESTNR;
            dwData["VKPKDKOMM"] = _KDKOMM;
            dwData["VKPFARBE"] = " AND VKPFARBE LIKE '" + FARBE + "%'";
            if (DTEND.Trim() == "")
                DTEND = "20150101";
            dwData["VKPLIEFTERM"] = DTEND;
            dwData["VKPEXAUFLFD"] = "";
            SResult = QVKP11(dwData);
            MergeData(SResult, true, true);
        }
        public DataRow YGRVKPFB(string _QCOND,ref bool IsCond)
        {

            dwData = TBMain.NewRow();
            dwData["VKPMANDANT"] = app.Mandant;
            dwData["VKPAUFKRS"] = KRS;
            if (KRS.Trim() == "")
            {
                dwData["VKPAUFKRS"] = "AA";
            }
            dwData["VKPAUFLFD"] = LFD;
            if (LFD.Trim() == "")
            {
                dwData["VKPAUFLFD"] = "";
            }
            else
            {
                dwData["VKPAUFLFD"] = Helper.Right("000000" + LFD, 6);

            }
            dwData["VKPKUNDNR"] = _KUNDNR;
            dwData["VKPKDBEZ"] = _YARNTYP;
            dwData["VKPAENDST"] = _YNE;
            dwData["VKPART"] = SPINLOT;

            //dwData["VKPSACHBE"] = _SACHBE;
            dwData["VKPFILLER2"] = _BESTNR;
            dwData["VKPKDKOMM"] = _KDKOMM;
            if (_LIEFTERM.Trim() == "")
                _LIEFTERM = "20150101";
            dwData["VKPLIEFTERM"] = _LIEFTERM;
            switch (_QCOND)
            {
                case "01":
                    IsCond = true;
                    dwData["VKPEXAUFLFD"] = " AND VKPEXART LIKE '%'";
                    break;
                case "02": 
                    dwData["VKPEXAUFLFD"] = " AND   SUBSTR(VKPEXART,2,1) <>'.'"; 
                    break;
                case "03"://
                    IsCond = true;
                    dwData["VKPEXAUFLFD"] = " AND  VKPEXAUFLFD<>'000000' AND SUBSTR(VKPEXART,1,2)='1.'";
                    break;
                case "04":
                    IsCond = true;
                    dwData["VKPEXAUFLFD"] = " AND  VKPEXAUFLFD<>'000000' AND SUBSTR(VKPEXART,1,2)='2.'";
                    break;
                case "05":
                    IsCond = true;
                    dwData["VKPEXAUFLFD"] = " AND  VKPEXAUFLFD<>'000000' AND SUBSTR(VKPEXART,1,2)='3.'";
                    break;
                default:
                    break;
            }
            if(!IsCond) 
            {
                SResult = QVKP11A(dwData);
                MergeData(SResult, true, true);
            }
            return dwData;
        }
    }

}
